<template>
	<!-- 提示确认框 -->
	<Popup ref="popup" type="center" :mask-click="false" class="Popup" :catchtouchmove="true">
		<view class="slot-view">
			<!-- 标题 -->
			<view class="title" v-if="title" :style="{fontSize: titleSize+'rpx',padding: titlePadding}">
				<text>{{title}}</text>
				<image src="/static/mine/model_popup_close.png" mode="" @click="cancel()" v-if="showCloseIcon"></image>
			</view>
			<!-- 内容 -->
			<view class="toast-text" :style="{textAlign: align,padding: contentPadding}">
				<text>
					{{content}}
				</text>
			</view>
			<!-- 按钮组 -->
			<view class="btn-box" :class="{'-active': showCancel && showConfirm}">
				<view class="cancel-btn" hover-class="hover-class" @click="cancel()" v-if="showCancel" :style="{
					color: cancelColor
				}" :class="{'-active':showCancel && showConfirm}">
					<text>{{cancelText}}</text>
				</view>
				<view class="confirm-btn" @click="confirm()" v-if="showConfirm" :style="{
					color: confirmColor
				}" :class="{'-active':showCancel && showConfirm}">
					<text>{{confirmText}}</text>
				</view>
			</view>
		</view>
	</Popup>
</template>

<script>
	import Popup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
	export default {
		props: {
			// 标题
			title: {
				type: String,
				default: ""
			},
			// 标题大小
			titleSize: {
				type: [String, Number],
				default: 40
			},
			// 提示内容
			content: {
				type: String,
				default: ""
			},
			// show cancel btn
			showCancel: {
				type: Boolean,
				default: true
			},
			// show confirm btn
			showConfirm: {
				type: Boolean,
				default: true
			},
			// 取消图标
			showCloseIcon: {
				type: Boolean,
				default: false
			},
			// 文字对齐方式
			align: {
				type: String,
				default: 'center'
			},
			// 标题内边距
			titlePadding:{
				type: String,
				default: "20rpx 30rpx"
			},
			// 内容内边距
			contentPadding: {
				type: String,
				default: "20rpx 20rpx 40rpx"
			},
			// 取消文字
			cancelText: {
				type: String,
				default: "我知道了"
			},
			// 确认文字
			confirmText: {
				type: String,
				default: "继续支付"
			},
			// 
			cancelColor: {
				type: String,
				default: "#222"
			},
			confirmColor: {
				type: String,
				default: "#FFF"
			}
		},
		components: {
			Popup
		},
		data() {
			return {

			}
		},
		methods: {
			cancel() {
				this.$refs.popup.close();
				this.$emit('close');
			},
			open() {
				this.$refs.popup.open('center');
			},
			confirm() {
				this.$refs.popup.close();
				this.$emit('confirm');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.slot-view {
		width: 90vw;
		padding: 30rpx 40rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 20rpx;
		border: 2rpx solid #7c7c7c;


		.title {
			position: relative;
			color: #1a1a1a;
			// padding-top: 20rpx;
			// padding-bottom: 20rpx;
			// padding-left: 30rpx;
			// padding-right: 30rpx;
			text-align: center;

			image {
				width: 36rpx;
				height: 36rpx;
				position: absolute;
				right: 0;
				top: 50%;
				transform: translateY(-50%);
			}
		}

		.toast-text {
			line-height: 50rpx;
			font-size: 30rpx;
			color: #343434;
			font-family: '宋体';
			max-height: 70vh;
			overflow: hidden;
		}

		.btn-box {

			&.-active {
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.cancel-btn {
				font-size: 32rpx;
				text-align: center;
				padding: 16rpx 0;
				border: 2rpx solid #cbcbcb;
				border-radius: 10rpx;
				box-sizing: border-box;

				&.-active {
					width: 47%;
				}

				&.hover-class {
					background-color: #F7F7F7;
				}
			}

			.confirm-btn {
				font-size: 32rpx;
				text-align: center;
				padding: 16rpx 0;
				border-radius: 10rpx;
				background-color: #F12F63;

				&.-active {
					width: 47%;
				}
			}

		}
	}
</style>
